<template>
  <div class="roadmap-page">
    <div class="pc">
      <div class="r-p-top">
        <img :src="images.title" />
      </div>

      <div class="r-p-center">
        <div
          class="center-card"
          :style="{ backgroundImage: `url('${item.image}')` }"
          v-for="(item, index) in cardsData"
          :key="index"
          @mouseenter="handleMouseEnter(index)"
          @mouseleave="handleMouseLeave"
        >
          <div class="card-title">{{ item.title }}</div>
          <div class="title-line"></div>

          <transition name="fade">
            <div class="card-mask" v-show="currentIndex === index">
              <div class="mask-title">{{ item.title }}</div>
              <div class="mask-line"></div>

              <div class="mask-desc">
                <div class="mask-desc-big">{{ item.desc_big }}</div>
                <div v-if="item.desc_big2" class="mask-desc-big">
                  {{ item.desc_big2 }}
                </div>
                <div v-if="item.desc_big3" class="mask-desc-big">
                  {{ item.desc_big3 }}
                </div>

                <div class="mask-desc-small" v-if="item.desc_small.length > 1">
                  <ul>
                    <li v-for="(desc, index) in item.desc_small" :key="index">
                      {{ desc }}
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </transition>
        </div>
      </div>
    </div>

    <div class="mobile">
      <div class="r-p-top">
        <img :src="images.title" />
      </div>

      <div ref="m-center" class="r-p-center">
        <swiper class="swiper" ref="mySwiper" :options="swiperOptions">
          <swiper-slide v-for="(item, index) in cardsData" :key="index">
            <div
              class="center-card"
              :style="{ backgroundImage: `url('${item.m_image}')` }"
              @click.stop="showMask(index)"
            >
              <div
                ref="m-card-title"
                class="card-title"
                :class="{ firstHidden: mCurrentIndex === index }"
              >
                {{ item.title }}
              </div>
              <div
                ref="m-card-line"
                class="title-line"
                :class="{ firstHidden: mCurrentIndex === index }"
              ></div>

              <transition name="fade">
                <div class="card-mask" v-show="mCurrentIndex === index">
                  <div ref="mask-title" class="mask-title">
                    {{ item.title }}
                  </div>
                  <div ref="mask-line" class="mask-line"></div>

                  <div ref="mask-desc" class="mask-desc">
                    <div class="mask-desc-big">{{ item.desc_big }}</div>
                    <div v-if="item.desc_big2" class="mask-desc-big">
                      {{ item.desc_big2 }}
                    </div>
                    <div v-if="item.desc_big3" class="mask-desc-big">
                      {{ item.desc_big3 }}
                    </div>

                    <div
                      class="mask-desc-small"
                      v-if="item.desc_small.length > 1"
                    >
                      <ul>
                        <li
                          v-for="(desc, index) in item.desc_small"
                          :key="index"
                        >
                          {{ desc }}
                        </li>
                      </ul>
                    </div>
                  </div>
                </div>
              </transition>
            </div>
          </swiper-slide>
        </swiper>
      </div>
    </div>
  </div>
</template>

<script>
// --- swiper ---
import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/swiper-bundle.css";
// --- utils ---
import { isPhone } from "@/utils";

export default {
  name: "RoadmapPage",
  components: {
    swiper,
    swiperSlide,
  },
  data() {
    return {
      // static
      images: {
        title: require("@/assets/images/roadmap/roadmap_title.png"),
      },
      // cards data
      cardsData: [
        {
          id: 1,
          title: "2022.07",
          desc_big: "* Official preparation for the launch of AotuWorld NFT",
          desc_small: [],
          image: require("@/assets/images/roadmap/roadmap_cartoon1.png"),
          m_image: require("@/assets/images/roadmap/m_roadmap_cartoon1.png"),
        },
        {
          id: 2,
          title: "2022 Q3",
          desc_big: "* Market Preview & Aotu wlrold NFTs on sale at：",
          desc_big2: "* A total of 8,888 AotuWrold NFTs are offered for sale.",
          desc_small: [
            "* Phase 1, Freemint, free distribution for early OG contributors.",
            "* Phase 2, NFT whitelist sale and public sale.",
          ],
          image: require("@/assets/images/roadmap/roadmap_cartoon2.png"),
          m_image: require("@/assets/images/roadmap/roadmap_cartoon2.png"),
        },
        {
          id: 3,
          title: "2022.Q4",
          desc_big:
            "* 1000 PASS cards on sale.And PASS cards are issued to NFT holders according to the rules.",
          desc_big2: "* AOTUNFT's brand co-branding cooperation is launched.",
          desc_big3:
            "* AOTUVerse home-creation products are launched, NFTPASS cards are used to share co-creation revenue.",
          desc_small: [],
          image: require("@/assets/images/roadmap/roadmap_cartoon3.png"),
          m_image: require("@/assets/images/roadmap/roadmap_cartoon3.png"),
        },
        {
          id: 4,
          title: "2023 Q1-Q2",
          desc_big: "* AOTU metaverse space in major metaverse platforms.",
          desc_big2:
            "* AOTUNFT co-branded physical goods are available for sale.",
          desc_big3: "* More than 50 AOTUCLUBs established worldwide.",
          desc_small: [],
          image: require("@/assets/images/roadmap/roadmap_cartoon4.png"),
          m_image: require("@/assets/images/roadmap/m_roadmap_cartoon4.png"),
        },
      ],
      // active
      currentIndex: 999,
      mCurrentIndex: 1,
      // swiper
      swiperOptions: {},
    };
  },
  methods: {
    // mouse enter to show card mask
    handleMouseEnter(index) {
      this.currentIndex = index;
    },
    // mouse leave to hidden card mask
    handleMouseLeave() {
      this.currentIndex = 999;
    },
    // mouse click to show card mask
    showMask(index) {
      this.mCurrentIndex = index;
      if (isPhone()) {
        this.$refs.mySwiper.swiper.slideTo(index);
      }
    },
    // mouse click to hidden card mask
    hiddenMask() {
      this.mCurrentIndex = 999;
    },
  },
  created() {
    const that = this;
    this.swiperOptions = {
      initialSlide: 1,
      slidesPerView: 1,
      // slidesPerView: "auto",
      // centerInsufficientSlides: true,
      centeredSlides: true,
      slidesPerGroup: 1,
      observer: true,
      observeParents: true,
      observeSlideChildren: true,
      spaceBetween: 30,
      autoplay: false,
      // allowTouchMove: false,
      // enabled: false,
      // simulateTouch: false,
      // updateTranslate: true,
      // touchRatio: 1,
      // shortSwipes: false,
      // navigation: {
      //   nextEl: ".swiper-button-next",
      //   prevEl: ".swiper-button-prev",
      // },
      on: {
        slideChangeTransitionStart() {
          that.mCurrentIndex = this.activeIndex;
        },
      },
    };
  },
  mounted() {
    if (isPhone()) {
      this.$refs["m-center"].scrollTo(150, 0);
    }

    // document.addEventListener("click", (e) => {
    //   if (e.target.className != "center-card") {
    //     this.mCurrentIndex = 999;
    //   }
    // });
  },
};
</script>

<style lang="less" scoped>
.roadmap-page {
  position: relative;
  width: 100%;
  height: 1080px;
  background-image: url("../../assets/images/roadmap/roadmap_background.png");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  margin-top: -21px;
  z-index: 4;
  user-select: none;

  .mobile {
    display: none;
  }

  .pc {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;

    // roadmap page top
    .r-p-top {
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      width: 654px;
      margin-top: 120px;

      img {
        display: block;
        width: 100%;
      }
    }

    // roadmap page center
    .r-p-center {
      display: flex;
      justify-content: space-between;
      width: 1200px;
      height: 600px;
      margin-top: 100px;

      .center-card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: relative;
        width: 288px;
        height: 100%;
        background-repeat: no-repeat;
        background-position: center center;
        background-size: 100% 100%;
        cursor: pointer;

        .card-title {
          font-size: 44px;
          font-family: DINAlternate-Bold, DINAlternate;
          font-weight: bold;
          color: #ffffff;
          line-height: 44px;
          text-shadow: 0px 2px 20px rgba(0, 0, 0, 0.5);
          transition: all 0.4s ease-out;
        }

        .title-line {
          width: 60px;
          height: 4px;
          background: #edaf33;
          margin: 10px auto 0 auto;
          transition: all 0.4s ease-out;
        }

        .card-mask {
          position: absolute;
          top: 0;
          left: 0;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          width: 100%;
          height: 100%;
          background: rgba(0, 0, 0, 0.79);

          .mask-title {
            font-size: 44px;
            font-family: DINAlternate-Bold, DINAlternate;
            font-weight: bold;
            color: #ffffff;
            line-height: 44px;
            text-shadow: 0px 2px 20px rgba(0, 0, 0, 0.5);
            transform: scale(0.5);
            transition: all 0.4s ease-out;
            text-align: center;
          }

          .mask-line {
            width: 60px;
            height: 4px;
            background: #edaf33;
            margin: 10px auto 0 auto;
            transform: scale(0.5);
            transition: all 0.4s ease-out;
          }

          .mask-desc {
            margin-top: 28px;
            transition: all 0.5s ease;
            transform: scale(0.5);
            max-height: 480px;
            overflow: auto;

            .mask-desc-big {
              width: 100%;
              box-sizing: border-box;
              padding: 0 21px;
              text-indent: -22px;
              padding-left: 44px;
              text-align: left;
              font-size: 22px;
              font-family: PingFangSC-Semibold, PingFang SC;
              font-weight: 600;
              color: #ffffff;
              line-height: 26px;
              margin-bottom: 20px;
            }

            .mask-desc-small {
              width: 100%;
              margin-top: 30px;

              ul,
              li {
                list-style: none;
                margin: 0;
                padding: 0;
              }

              ul {
                display: flex;
                flex-direction: column;
                box-sizing: border-box;
                padding: 0 30px 0 40px;
                width: 100%;
                height: 100%;

                li {
                  text-indent: -16px;
                  // padding-left: 16px;
                  font-size: 16px;
                  font-family: PingFangSC-Regular, PingFang SC;
                  font-weight: 400;
                  color: #ffffff;
                  line-height: 22px;
                  margin-bottom: 20px;
                }
              }
            }
          }
          .mask-desc::-webkit-scrollbar {
            display: none;
            width: 5px;
            border-radius: 3px;
          }
          .mask-desc::-webkit-scrollbar-track {
            border-radius: 3px;
            background: rgba(0, 0, 0, 0.1);
          }
          .mask-desc::-webkit-scrollbar-thumb {
            border-radius: 3px;
            background: #b58be0;
          }
        }
      }

      .center-card:hover .card-title,
      .center-card:hover .title-line {
        transform: translateY(-30px);
        opacity: 0;
      }
      .center-card:hover .mask-desc,
      .center-card:hover .mask-title,
      .center-card:hover .mask-line {
        transform: scale(1);
      }
    }
  }

  // animate
  .fade-enter-active,
  .fade-leave-active {
    transition: all 0.5s ease;
  }
  .fade-enter,
  .fade-leave-to {
    opacity: 0;
  }
}

@media screen and (max-width: 768px) {
  .roadmap-page {
    height: 154.6667vw;
    width: 100%;
    margin-top: 0;
    background-image: url("../../assets/images/roadmap/m_roadmap_background.png");

    .pc {
      display: none;
    }

    .mobile {
      height: 100%;
      width: 100%;
      display: flex;
      flex-direction: column;
      overflow: hidden;

      .r-p-top {
        display: flex;
        justify-content: center;
        margin-top: 6.9333vw;

        img {
          display: block;
          width: 70vw;
        }
      }

      .r-p-center {
        display: flex;
        justify-content: unset;
        width: 100%;
        width: 57.6vw;
        height: 120vw;
        margin: 0 auto;
        margin-top: 8vw;
        // overflow: auto;
        // margin-left: -40.5333vw;

        .swiper {
          padding: 0;
          margin: 0;
          width: 100%;
          height: 100%;
        }
        /deep/.swiper-container {
          overflow: unset;
          // touch-action: none;
        }

        .center-card {
          position: relative;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          background-repeat: no-repeat;
          background-position: center center;
          background-size: 100% 100%;
          min-width: 57.6vw;
          height: 100%;
          margin-right: 4vw;

          .card-title {
            font-size: 12vw;
            font-family: DINAlternate-Bold, DINAlternate;
            font-weight: bold;
            color: #ffffff;
            line-height: 12vw;
            text-shadow: 0px 4px 40px rgba(0, 0, 0, 0.5);
            transition: all 0.4s ease;
            text-align: center;
          }

          .title-line {
            width: 12vw;
            height: 0.8vw;
            background: #edaf33;
            margin: 1.6vw auto 0 auto;
            transition: all 0.4s ease;
          }

          .firstHidden {
            transform: translateY(-4vw);
            opacity: 0;
          }

          .card-mask {
            position: absolute;
            top: 0;
            left: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.79);

            .mask-title {
              font-size: 9.3333vw;
              font-family: DINAlternate-Bold, DINAlternate;
              font-weight: bold;
              color: #ffffff;
              font-size: 9.3333vw;
              text-shadow: 0px 4px 40px rgba(0, 0, 0, 0.5);
              // transform: scale(0.5);
              transition: all 0.4s ease;
              text-align: center;
            }

            .mask-line {
              width: 12vw;
              height: 0.8vw;
              background: #edaf33;
              margin: 1.3333vw auto 0 auto;
              // transform: scale(0.5);
              transition: all 0.4s ease;
            }

            .mask-desc {
              transition: all 0.5s ease;
              // transform: scale(0.5);
              max-height: 69.3333vw;
              padding: 0;
              overflow: auto;
              margin-top: 5.8667vw;

              .mask-desc-big {
                font-size: 4.2667vw;
                font-family: PingFangSC-Semibold, PingFang SC;
                font-weight: 600;
                color: #ffffff;
                line-height: 4.8vw;
                text-align: left;
                box-sizing: border-box;
                padding: 0 4vw;
                text-indent: -4.2667vw;
                padding-left: 8.2667vw;
                margin-bottom: 2.6667vw;
              }

              .mask-desc-small {
                margin-top: 5.0667vw;

                ul,
                li {
                  list-style: none;
                  margin: 0;
                  padding: 0;
                }

                ul {
                  display: flex;
                  flex-direction: column;
                  box-sizing: border-box;

                  width: 100%;
                  height: 100%;
                  padding: 0 4vw;

                  li {
                    text-indent: -3.4667vw;
                    padding-left: 3.4667vw;
                    font-size: 3.4667vw;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #ffffff;
                    line-height: 5.3333vw;
                    margin-bottom: 2.6667vw;
                  }
                }
              }
            }
            .mask-desc::-webkit-scrollbar {
              display: none;
              width: 0.6667vw;
              border-radius: 3px;
            }
            .mask-desc::-webkit-scrollbar-track {
              border-radius: 3px;
              background: rgba(0, 0, 0, 0.1);
            }
            .mask-desc::-webkit-scrollbar-thumb {
              border-radius: 3px;
              background: #b58be0;
            }
          }
        }

        .center-card:last-child {
          margin-right: 0;
        }

        // .center-card:hover .card-title,
        // .center-card:hover .title-line {
        //   transform: translateY(-4vw);
        //   opacity: 0;
        // }
        // .center-card:hover .mask-desc,
        // .center-card:hover .mask-title,
        // .center-card:hover .mask-line {
        //   // transform: scale(1);
        // }
      }

      .r-p-center::-webkit-scrollbar {
        display: none;
      }
    }
  }
}
</style>
